<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="commons/head::myhead(~{::title},~{::link})">
	<title>useradd</title>
	<!-- main CSS -->
	<link href="asserts/css/main.css" th:href="@{/asserts/css/main.css}" rel="stylesheet">
</head>
<body>
	<!--引入topbar-->
    <div th:replace="commons/bar::topbar"></div>
    <div class="container-fluid">
        <div class="row">
            <!--引入sidebar-->
            <div th:replace="commons/bar::#sidebar(activeUri='userlist')"></div>
            <main role="main" class="col-md-10 ml-sm-auto col-lg-10 pt-3 px-4">
				<form action="commons/success.html" th:action="@{/main/user}" method="POST">
					<!-- 修改用户发送PUT请求 -->
					<!--
					1、SpringMVC中配置HiddenHttpMethodFilter;（SpringBoot自动配置好的）
					2、页面创建一个post表单
					3、创建一个input项，name="_method";值就是我们指定的请求方式
					-->
					<input type="hidden" name="_method" value="PUT" th:if="${user!=null}"/>
					<input type="hidden" name="id" th:if="${user!=null}" th:value="${user.id}"/>

					<div class="form-group">
						<label>[[#{user.name}]]</label>
						<input class="form-control" name="username" type="text" placeholder="Username" th:placeholder="#{user.name}" th:value="${user!=null}?${user.username}"/>
					</div>
					<div class="form-group">
						<label>[[#{common.password}]]</label>
						<input class="form-control" name="password" type="text" placeholder="Password" th:placeholder="#{common.password}" th:value="${user!=null}?${user.password}"/>
					</div>
					<div class="form-group">
						<label>[[#{common.email}]]</label>
						<input class="form-control" name="email" type="email" placeholder="Email" th:placeholder="#{common.email}" th:value="${user!=null}?${user.email}"/>
					</div>
					<div class="form-group">
						<label>[[#{common.phone.number}]]</label>
						<input class="form-control" name="phoneNumber" type="text" placeholder="PhoneNumber" th:placeholder="#{common.phone.number}" th:value="${user!=null}?${user.phoneNumber}"/>
					</div>
					<div class="form-group">
						<label>[[#{user.authority}]]</label>
						<select class="form-control" name="authority">
							<option th:each="authority:${authoritys}" th:text="${authority.value}" th:value="${authority}" th:selected="${user!=null}?${authority == user.authority}">1</option>
						</select>
					</div>
					<div class="form-group">
						<label>[[#{common.note}]]</label>
						<textarea class="form-control" name="note" rows="3" >[[${user!=null}?${user.note}]]</textarea>
					</div>
					<button type="submit" class="btn btn-primary" th:text="${user!=null}?#{btn.update}:#{btn.add}">Submit</button>
				</form>
            </main>
        </div>
    </div>

    <div th:replace="commons/head::myscript(~{::script})">
        <script type="text/javascript"></script>
	</div>
</body>
</html>